﻿import QtQuick 2.0
import "./components"
import QtQuick.Window 2.12
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.2
import QtQuick.Controls 2.12
import QtMultimedia 5.14

ApplicationWindow {
    id: root
    readonly property real dp: config.dp
    property var error_text: ""
    property var method_text: ""

    width: 500*dp
    height: 300*dp
    minimumHeight: 300*dp
    maximumHeight: 300*dp
    minimumWidth: 500*dp
    maximumWidth: 500*dp
    title: "请选择耗材"
    modality: Qt.WindowModal
    flags: Qt.Window | Qt.WindowTitleHint |Qt.WindowSystemMenuHint | Qt.WindowCloseButtonHint

    onVisibleChanged: {
        expType.model=GetMessageInterface.getConsumablesName()
        var data=GetMessageInterface.getDefaultExeConfig()
        expType.setText(data[0])
        expName.model=GetMessageInterface.getExperimentNameByConsumables(expType.getText())
        expName.setText(data[1])

        expConsumblesTypeName=expType.getText()
        expConsumblesTypeIndex=expType.getIndex()
        expSettingName=expName.getText()
        expSettingIndex=expName.getIndex()
    }

    Rectangle{
        CustomComboBox {
            id:expType
            x:104*dp
            y:30*dp
            height: 40*dp
            width: 220*dp
            title: "耗材名称"
            onCurrentText: {
                expName.model=GetMessageInterface.getExperimentNameByConsumables(text)
            }
        }
        CustomComboBox {
            id:expName
            x:104*dp
            y:90*dp
            height: 40*dp
            width: 2220*dp
            title: "实验名称"
        }

    }

    CustomButton{
        title: "取消"
        defaultMode2: true
        x: 122*dp
        y: 170*dp
        onReleased: {
            close()
        }
    }
    CustomButton{
        title: "确定"
        defaultMode1: true
        x: 258*dp
        y: 170*dp
        onReleased: {
            expConsumblesTypeName=expType.getText()
            expConsumblesTypeIndex=expType.getIndex()
            expSettingName=expName.getText()
            expSettingIndex=expName.getIndex()
            CommunicationMethod.setConsumable(expType.getText());
            CAnimation.reset()
            close()
        }
    }
}
